#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
    typedef pair<double,double> pii;
    double maxProbability(int n, vector<vector<int>>& edges, vector<double>& succProb, int start, int end) {
        vector<vector<pii>> g(n);
        for(int i=0;i<edges.size();i++)
        {
            g[edges[i][0]].emplace_back(edges[i][1],succProb[i]);
            g[edges[i][1]].emplace_back(edges[i][0],succProb[i]);
        }
        vector<double> d(n,-1);
        priority_queue<pii,vector<pii>> q;
        d[start]=1;
        q.emplace(1,start);
        while(!q.empty())
        {
            auto [t_x,x]=q.top();
            q.pop();
            if(t_x<d[x]) continue;
            for(auto& [y,t_y]:g[x])
            {
                double new_t=t_x*t_y;
                if(new_t>d[y])
                {
                    d[y]=new_t;
                    q.emplace(new_t,y);
                }
            }
        }
        return d[end]==-1?0:d[end];
    }
};